#include <stdio.h>
#include <stdlib.h>

typedef struct TreeNode
{
    char val;
    struct TreeNode* left;
    struct TreeNode* right;
}TreeNode;

TreeNode* CreateTree(char* a, int* i)
{
    if (a[(*i)] == '#')
    {
        (*i)++;
        return NULL;
    }

    TreeNode* root = (TreeNode*)malloc(sizeof(TreeNode));
    root->val = a[(*i)++];
    root->left = CreateTree(a, i);
    root->right = CreateTree(a, i);

    return root;
}

void Inorder(struct TreeNode* root)
{
    if (root == NULL)
        return;
    Inorder(root->left);
    printf("%c ", root->val);
    Inorder(root->right);
}

int main() {
    char a[100];
    scanf("%s", a);
    int i = 0;
    TreeNode* root = CreateTree(a, &i);
    Inorder(root);
    return 0;
}